const keyName = "aiShop-";
/**
 * 存储localStorage
 */
export const setStore = (params = {}) => {
  let { name, content, useLocal } = params;
  name = keyName + name;
  if (useLocal) {
    window.localStorage.setItem(name, JSON.stringify(content));
  } else window.sessionStorage.setItem(name, JSON.stringify(content));
};
/**
 * 获取localStorage
 */

export const getStore = (params = {}) => {
  let { name, useLocal } = params;
  name = keyName + name;
  if (useLocal) {
    return window.localStorage.getItem(name);
  } else return window.sessionStorage.getItem(name);
};
/**
 * 删除localStorage
 */
export const removeStore = (params = {}) => {
  let { name, useLocal } = params;
  name = keyName + name;
  if (useLocal) {
    window.localStorage.removeItem(name);
  } else {
    window.sessionStorage.removeItem(name);
  }
};

/**
 * 清空全部localStorage
 */
export const clearStore = (params = {}) => {
  let { useLocal } = params;
  if (useLocal) {
    window.localStorage.clear();
  } else {
    window.sessionStorage.clear();
  }
};
